<template>
    <div id="worker">
        <el-form :inline="true" :model="formInline">
            <el-form-item>
                <el-input v-model="formInline.username" placeholder="用户名"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="addWorker">新增</el-button>
            </el-form-item>
        </el-form>
        <el-table
            :header-cell-style="{color:'#555555'}"
            class="black"
            :data="tableData"
            stripe
            border
            style="width: 100%">
            <el-table-column
                prop="userId"
                label="ID"
                align="center">
            </el-table-column>
            <el-table-column
                prop="username"
                label="用户名"
                align="center">
            </el-table-column>
            <el-table-column
                prop="mobile"
                label="手机号码"
                align="center">
            </el-table-column>
            <el-table-column
                prop="createTime"
                label="新增时间"
                align="center">
            </el-table-column>
            <el-table-column
                prop="password"
                v-if="show = false">
            </el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button @click="onEditData(scope.row)" size="small">编辑</el-button>
                    <el-button @click="onDelData(scope.row)" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="footer-page">
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="page"
                :page-sizes="[10, 20, 50, 100]"
                :page-size="page_size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total_count">
            </el-pagination>
        </div>
        <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="30%">
            <span>确认删除吗？</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="onSureClick">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    name: 'user-man-detail',
    data () {
        return {
            dialogVisible: false,
            del_id: '',
            tableData: [],
            page: 1,
            page_size: 10,
            total_count: 0,
            params: {
                page: 1,
                limit: 10,
                order: 'asc'
            },
            formInline: {
                username: ''
            }
        }
    },
    created () {
    },
    mounted () {
        // 获取详情数据
        this.getData({'params': this.params})
    },
    methods: {
        handleRemove (file, fileList) {
            console.log(file, fileList)
        },
        onDelData (row) {
            this.del_id = row.id
            this.dialogVisible = true
            console.log(this.dialogImageUrl)
        },
        onSureClick () {
            this.dialogVisible = false
            this.deleteData(this.del_id)
        },
        // 系统参数列表
        getData (data) {
            var _this = this
            this.$api.system.sysUserList(data, res => {
                // 隐藏加载动画
                // this.$vux.loading.hide()
                if (res.code === 200) {
                    var data = res.page.list
                    _this.tableData = data
                    this.page = res.page.currentPage
                    this.page_size = res.page.pageSize
                    this.total_count = res.page.totalCount
                }
            })
        },
        deleteData (id) {

        },
        onEditData () {
            this.$router.push({
                name: 'system.sourseWorker',
                params: {
                }
            })
        },
        // 更新系统参数
        addWorker () {
            this.$router.push({
                name: 'system.sourseWorker',
                params: {
                }
            })
        },
        handleSizeChange (val) {
            this.page_size = val
            this.params.limit = val
            this.params.page = this.page
            this.getList({'params': this.params})
        },
        handleCurrentChange (val) {
            this.page = val
            this.params.page = val
            this.params.limit = this.page_size
            this.getList({ 'params': this.params })
        }
    }
}
</script>

<style lang="less" scoped>
    #worker {
        position: relative;
        width: 100%;
        height: 100%;
        .margin-bottom-12 {
            margin-bottom: 10px;
        }
        .el-row {
            margin-bottom: 20px;
            &:last-child {
                margin-bottom: 0;
            }
        }
        .el-col {
            border-radius: 4px;
        }
        .grid-content {
            position: relative;
            height: 40px;
        }
        .grid-padding {
            /* padding-left: 20px; */
            padding-right: 20px;
        }
        .grid-title {
            float: left;
            width: 72px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .grid-input {
            float: left;
            width: 130px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #333;
            text-align: center;
        }
        .row-bg {
            padding: 10px 0;
            background-color: #f9fafc;
        }
        .footer-page {
            width: 540px;
            margin: 0 auto;
            padding-top: 20px;
        }
    }
</style>
